package com.donghua.service;

import com.donghua.dao.UserMapper;
import com.donghua.entity.User;
import com.donghua.util.CommunityConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService implements CommunityConstant {

    @Autowired
    private UserMapper userMapper;

    @Autowired UserService userService;

    public User findUserById(int id) {
        return userMapper.selectById(id);
    }

//    public void updatePassword(UserVO user) {
//        // 校验账号是否合法
//        if (!checkUser(user)) {
//            throw new BizException(StatusCodeEnum.EMAIL_NOT_REGISTER.getCode(), "邮箱尚未注册！");
//        }
//        // 根据用户名修改密码(用户名就是邮箱)
//        userMapper.updatePassword(userMapper.selectByName(user.getUsername()).getId(), user.getPassword());
//    }


    public int updateHeader(int userId, String headerUrl) {
        return userMapper.updateHeader(userId, headerUrl);
    }

    public int updateBackGround(int userId, String backgroundUrl) {
        return userMapper.updateBackground(userId, backgroundUrl);
    }

    public User findUserByName(String username) {
        return userMapper.selectByName(username);
    }

    public User findUserByNickName(String nickName) {
        return userMapper.selectByNickName(nickName);
    }

    public int updateNickName(int userId, String nickName) {
        return userMapper.updateNickName(userId, nickName);
    }

    public int updateDescription(int userId, String description) {
        return userMapper.updateDescription(userId, description);
    }

}
